package com.cskaoyan.service;

import com.cskaoyan.mapper.ConfigMapper;
import com.cskaoyan.mapper.SystemMapper;
import com.cskaoyan.model.bean.ConfigManage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author：Chunk
 * @Description:
 * @Date Created in 10:27 2021/4/11
 */
@Service
public class ConfigServiceImpl implements ConfigService {
    @Autowired
    ConfigMapper configMapper;

    @Override
    public ConfigManage queryMall() {
        String cskaoyanmallMallAddress = "cskaoyan_mall_mall_address";
        String cskaoyanmallMallName = "cskaoyan_mall_mall_name";
        String cskaoyanmallMallPhone = "cskaoyan_mall_mall_phone";
        String cskaoyanmallMallQq = "cskaoyan_mall_mall_qq";

        ConfigManage configManage = new ConfigManage();

        configManage.setCskaoyanmall_mall_name(configMapper.quaryKey(cskaoyanmallMallName));
        configManage.setCskaoyanmall_mall_address(configMapper.quaryKey(cskaoyanmallMallAddress));
        configManage.setCskaoyanmall_mall_phone(configMapper.quaryKey(cskaoyanmallMallPhone));
        configManage.setCskaoyanmall_mall_qq(configMapper.quaryKey(cskaoyanmallMallQq));
        return configManage;
    }

    @Override
    public void updateMall(ConfigManage configManage) {
        Integer i1 = configMapper.updateKey("cskaoyan_mall_mall_address", configManage.getCskaoyanmall_mall_address());
        Integer i2 = configMapper.updateKey("cskaoyan_mall_mall_qq", configManage.getCskaoyanmall_mall_qq());
        Integer i3 = configMapper.updateKey("cskaoyan_mall_mall_name", configManage.getCskaoyanmall_mall_name());
        Integer i4 = configMapper.updateKey("cskaoyan_mall_mall_phone", configManage.getCskaoyanmall_mall_phone());
    }

    @Override
    public ConfigManage queryExpress() {
        ConfigManage configManage = new ConfigManage();
        configManage.setCskaoyanmall_express_freight_value(configMapper.quaryKey("cskaoyan_mall_express_freight_value"));
        configManage.setCskaoyanmall_express_freight_min(configMapper.quaryKey("cskaoyan_mall_express_freight_min"));
        return configManage;
    }

    @Override
    public void updateExpress(ConfigManage configManage) {
        Integer i1 = configMapper.updateKey("cskaoyan_mall_express_freight_min", configManage.getCskaoyanmall_express_freight_min());
        Integer i2 = configMapper.updateKey("cskaoyan_mall_express_freight_value", configManage.getCskaoyanmall_express_freight_value());
    }

    @Override
    public ConfigManage queryOrder() {
        ConfigManage configManage = new ConfigManage();
        configManage.setCskaoyanmall_order_comment(configMapper.quaryKey("cskaoyan_mall_order_comment"));
        configManage.setCskaoyanmall_order_unconfirm(configMapper.quaryKey("cskaoyan_mall_order_unconfirm"));
        configManage.setCskaoyanmall_order_unpaid(configMapper.quaryKey("cskaoyan_mall_order_unpaid"));
        return configManage;
    }

    @Override
    public void updateOrder(ConfigManage configManage) {
        Integer i1 = configMapper.updateKey("cskaoyan_mall_order_unconfirm", configManage.getCskaoyanmall_order_unconfirm());
        Integer i2 = configMapper.updateKey("cskaoyan_mall_order_unpaid", configManage.getCskaoyanmall_order_unpaid());
        Integer i3 = configMapper.updateKey("cskaoyan_mall_order_comment", configManage.getCskaoyanmall_order_comment());
    }

    @Override
    public ConfigManage queryWx() {
        ConfigManage configManage = new ConfigManage();
        configManage.setCskaoyanmall_wx_catlog_list(configMapper.quaryKey("cskaoyan_mall_wx_catlog_list"));
        configManage.setCskaoyanmall_wx_catlog_goods(configMapper.quaryKey("cskaoyan_mall_wx_catlog_goods"));
        configManage.setCskaoyanmall_wx_index_brand(configMapper.quaryKey("cskaoyan_mall_wx_index_brand"));
        configManage.setCskaoyanmall_wx_index_hot(configMapper.quaryKey("cskaoyan_mall_wx_index_hot"));
        configManage.setCskaoyanmall_wx_index_new(configMapper.quaryKey("cskaoyan_mall_wx_index_new"));
        configManage.setCskaoyanmall_wx_index_topic(configMapper.quaryKey("cskaoyan_mall_wx_index_topic"));
        configManage.setCskaoyanmall_wx_share(configMapper.quaryKey("cskaoyan_mall_wx_share"));
        return configManage;
    }

    @Override
    public void updateWx(ConfigManage configManage) {
        String goods = configManage.getCskaoyanmall_wx_catlog_goods();
        String list = configManage.getCskaoyanmall_wx_catlog_list();
        String brand = configManage.getCskaoyanmall_wx_index_brand();
        String hot = configManage.getCskaoyanmall_wx_index_hot();
        String aNew = configManage.getCskaoyanmall_wx_index_new();
        String topic = configManage.getCskaoyanmall_wx_index_topic();
        String share = configManage.getCskaoyanmall_wx_share();

        configMapper.updateKey("cskaoyan_mall_wx_catlog_list", list);
        configMapper.updateKey("cskaoyan_mall_wx_catlog_goods", goods);
        configMapper.updateKey("cskaoyan_mall_wx_index_brand", brand);
        configMapper.updateKey("cskaoyan_mall_wx_index_hot", hot);
        configMapper.updateKey("cskaoyan_mall_wx_index_new", aNew);
        configMapper.updateKey("cskaoyan_mall_wx_index_topic", topic);
        configMapper.updateKey("cskaoyan_mall_wx_share", share);
    }
}
